<template>
  <div class="detail">
    <!-- 备选库 -->
    <transition name="slide">
      <div class="container" v-show="slide">
        <div class="mask" v-if="show" @click="isSlide"></div>
        <div class="detail-main">
          <div class="switch" @click="isSlide"> <i class="icon icon-leftArrow"></i> </div>
          <vue-scroll>
          <div class="detail-content">
            <slot></slot>
          </div>
          </vue-scroll>
        </div>
      </div>
    </transition>

  </div>
</template>

<script>
export default {
  data () {
    return {
      slide: false
    }
  },
  props: {
    show: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    isSlide () {
      this.slide = !this.slide
      this.$emit('bindevent', this.slide)
    }
  },
  mounted: function () {
    this.$on('event', function (msg = true) {
      this.slide = msg
    })
  }
}
</script>

<style scoped lang="scss">
  $titleW:55px;
  $contentW:820px;

  .detail{
    position:fixed; right:0px; top:0px; z-index:11;
    height:100%;

    .container{
      position:relative; z-index:2;
      padding-top:50px;
      width:$titleW+$contentW;
      height:100%;
      display:flex;
      // transition: all .5s;
      .mask{
        position:absolute; right:0px; top:0px; z-index:1;
        height:100%; width:1000%;
        background:$mask;
      }
      &.slide-enter{
        transform:translateX($contentW)
        // transform:translateX(100%)
      }
      &.slide-enter-active{
        transition: all .5s;
      }
      // &.slide-enter-to{
      //   transform:translateX(0)
      // }
      // &.slide-leave-active{
      //   transform:translateX(100%);
      //   transition: all .5s;
      // }

      .detail-main{
        position:relative; z-index:2;
        height:100%; width:100%;
        display:flex;
        box-shadow:-2px 0 5px $shadow;
        background:$light;
        .switch{
          width:$titleW; height:100%;
          display:flex;
          align-items: center;
          flex-direction: column;
          justify-content: center;
          cursor:pointer;
          i{
            transform: rotate(180deg);
            color:#D6D6D6;
          }
        }
        .detail-content{
          // overflow-y:scroll;
          padding:20px 20px 20px 0;
          flex:1;
        }
      }
    }
  }
</style>
